home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 May: Tool Chest / Dev.CD May 97 TC.toast / Tool Chest / QuickDraw / Virtual Sphere 1.0.1 / Virtual Sphere Sample Code 1.1 / Sample.h < prev    next >
Encoding:
Text File  |  1993-03-25  |  8.9 KB  |  217 lines  |  [TEXT/MPS ]

  1. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  2. /* Sample.h
  3. /*
  4. /* Modified for Virtual Sphere Sample Code Release v1.1
  5. /*
  6. /* Author: Michael Chen, Human Interface Group / ATG
  7. /* Copyright © 1991-1993 Apple Computer, Inc.  All rights reserved.
  8. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  9. /*------------------------------------------------------------------------------
  10. #
  11. #    Apple Macintosh Developer Technical Support
  12. #
  13. #    MultiFinder-Aware Simple Sample Application
  14. #
  15. #    Sample
  16. #
  17. #    Sample.h    -    Rez and C Include Source
  18. #
  19. #    Copyright © Apple Computer, Inc. 1989-1990
  20. #    All rights reserved.
  21. #
  22. #    Versions:    
  23. #                1.00                08/88
  24. #                1.01                11/88
  25. #                1.02                04/89    MPW 3.1
  26. #                1.03                02/90    MPW 3.2
  27. #
  28. #    Components:
  29. #                Sample.c            Feb.  1, 1990
  30. #                Sample.r            Feb.  1, 1990
  31. #                Sample.h            Feb.  1, 1990
  32. #                Sample.make            Feb.  1, 1990
  33. #
  34. #    Sample is an example application that demonstrates how to
  35. #    initialize the commonly used toolbox managers, operate 
  36. #    successfully under MultiFinder, handle desk accessories, 
  37. #    and create, grow, and zoom windows.
  38. #
  39. #    It does not by any means demonstrate all the techniques 
  40. #    you need for a large application. In particular, Sample 
  41. #    does not cover exception handling, multiple windows/documents, 
  42. #    sophisticated memory management, printing, or undo. All of 
  43. #    these are vital parts of a normal full-sized application.
  44. #
  45. #    This application is an example of the form of a Macintosh 
  46. #    application; it is NOT a template. It is NOT intended to be 
  47. #    used as a foundation for the next world-class, best-selling, 
  48. #    600K application. A stick figure drawing of the human body may 
  49. #    be a good example of the form for a painting, but that does not 
  50. #    mean it should be used as the basis for the next Mona Lisa.
  51. #
  52. #    We recommend that you review this program or TESample before 
  53. #    beginning a new application.
  54. ------------------------------------------------------------------------------*/
  55.  
  56. /*    These #defines correspond to values defined in the Pascal source code.
  57.     Sample.c and Sample.r include this file. */
  58.  
  59. /*    Determining an application's minimum size to request from MultiFinder depends
  60.     on many things, each of which can be unique to an application's function,
  61.     the anticipated environment, the developer's attitude of what constitutes
  62.     reasonable functionality and performance, etc. Here is a list of some things to
  63.     consider when determining the minimum size (and preferred size) for your
  64.     application. The list is pretty much in order of importance, but by no means
  65.     complete.
  66.     
  67.     1.    What is the minimum size needed to give almost 100 percent assurance
  68.         that the application won't crash because it ran out of memory? This
  69.         includes not only things that you do have direct control over such as
  70.         checking for NIL handles and pointers, but also things that some
  71.         feel are not so much under their control such as QuickDraw and the
  72.         Segment Loader.
  73.         
  74.     2.    What kind of performance can a user expect from the application when
  75.         it is running in the minimum memory configuration? Performance includes
  76.         not only speed in handling data, but also things like how many documents
  77.         can be opened, etc.
  78.         
  79.     3.    What are the typical sizes of scraps [is a boy dog] that a user might
  80.         wish to work with when lauching or switching to your application? If
  81.         the amount of memory is too small, the scrap may get lost [will have
  82.         to be shot]. This can be quite frustrating to the user.
  83.         
  84.     4.    The previous items have concentrated on topics that tend to cause an
  85.         increase in the minimum size to request from MultiFinder. On the flip
  86.         side, however, should be the consideration of what environments the
  87.         application may be running in. There may be a high probability that
  88.         many users with relatively small memory configurations will want to
  89.         avail themselves of your application. Or, many users might want to use it
  90.         while several other, possibly related/complementary applications are
  91.         running. If that is the case, it would be helpful to have a fairly
  92.         small minimum size.
  93.     
  94.     So, what did we decide on Sample? First, Sample has little risk of
  95.     running out of memory once it starts. Second, performance isn't much
  96.     of an issue since it doesn't do much and multiple windows are not
  97.     allowed. Third, there are no edit operations in Sample itself, so we
  98.     just want to provide enough space for a reasonable scrap to survive
  99.     between desk accessory launches. Lastly, Sample should intrude as little
  100.     as possible, so the effort should be towards making it as small as possible.
  101.     We looked at some heap dumps while the application was running under
  102.     various partition sizes. With a size of 23K, there was approximately
  103.     8-9K free, which is a good 'slop' factor in an application like this
  104.     which doesn't do much, but where we'd still like the scrap to survive
  105.     most of the time. */
  106.  
  107. #define kMinSize    150                /* application's minimum size (in K) */
  108.  
  109. /*    We made the preferred size bigger than the minimum size by 12K, so that
  110.     there would be even more room for the scrap, FKEYs, etc. */
  111.  
  112. #define kPrefSize    200                /* application's preferred size (in K) */
  113.  
  114. #define    rMenuBar        128                /* application's menu bar */
  115. #define    rAboutAlert        128                /* about alert */
  116. #define    rUserAlert        129                /* error user alert */
  117. #define    rMessageAlert    130                /* message alert */
  118. #define    rWindow            128                /* application's window */
  119.  
  120. #define    rDitherPatterns    128            /* Dither patterns rsrc # */
  121.  
  122. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  123.    SysEnvRec we understand. */
  124.  
  125. #define    kSysEnvironsVersion        1
  126.  
  127. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  128.    by MultiFinder. Once we determine that an event is an osEvent, we look at the
  129.    high byte of the message sent to determine which kind it is. To differentiate
  130.    suspend and resume events we check the resumeMask bit. */
  131.  
  132. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  133. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  134. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  135. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  136. #define    kNoEvents                0        /* no events mask */
  137.  
  138. /* The following constants are used to identify menus and their items. The menu IDs
  139.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  140.  
  141. #define    mApple                    128        /* Apple menu */
  142. #define    iAbout                    1
  143.  
  144. #define    mFile                    129        /* File menu */
  145. #define    iNew                    1
  146. #define    iClose                    4
  147. #define    iQuit                    12
  148.  
  149. #define    mEdit                    130        /* Edit menu */
  150. #define    iUndo                    1
  151. #define    iCut                    3
  152. #define    iCopy                    4
  153. #define    iPaste                    5
  154. #define    iClear                    6
  155.  
  156. #define    mObject                        131        /* Object menu */
  157. #define    iCube                        1
  158. #define    iIcosahedron                2
  159. #define    iHouse                        3
  160.  
  161. #define    mOptions                    132        /* Options menu */
  162. #define    iLineDrawing                1
  163. #define    iFlatShading                2
  164. #define    iFlatShadingWithOutline        3
  165. #define    iDrawInBW                    5
  166. #define    iDrawInColor                6
  167. #define    iBackfacedPolygonRemoval    8
  168. #define    iDoubleBuffer                9
  169.  
  170. /*    1.01 - kTopLeft - This is for positioning the Disk Initialization dialogs. */
  171.  
  172. #define kDITop                    0x0050
  173. #define kDILeft                    0x0070
  174.  
  175. /*    1.01 - kMinHeap - This is the minimum result from the following
  176.     equation:
  177.         
  178.         ORD(GetApplLimit) - ORD(ApplicZone)
  179.         
  180.     for the application to run. It will insure that enough memory will
  181.     be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  182.     application, and still give the application some 'breathing room'.
  183.     To derive this number, we ran under a MultiFinder partition that was
  184.     our requested minimum size, as given in the 'SIZE' resource. */
  185.      
  186. #define kMinHeap                21 * 1024
  187.     
  188. /*    1.01 - kMinSpace - This is the minimum result from PurgeSpace, when called
  189.     at initialization time, for the application to run. This number acts
  190.     as a double-check to insure that there really is enough memory for the
  191.     application to run, including what has been taken up already by
  192.     pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  193.      
  194. #define kMinSpace                8 * 1024
  195.  
  196. /* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  197.  
  198. #define kExtremeNeg                -32768
  199. #define kExtremePos                32767 - 1 /* required to address an old region bug */
  200.  
  201. /* these #defines are used to set enable/disable flags of a menu */
  202.  
  203. #define AllItems    0b1111111111111111111111111111111    /* 31 flags */
  204. #define NoItems        0b0000000000000000000000000000000
  205. #define MenuItem1    0b0000000000000000000000000000001
  206. #define MenuItem2    0b0000000000000000000000000000010
  207. #define MenuItem3    0b0000000000000000000000000000100
  208. #define MenuItem4    0b0000000000000000000000000001000
  209. #define MenuItem5    0b0000000000000000000000000010000
  210. #define MenuItem6    0b0000000000000000000000000100000
  211. #define MenuItem7    0b0000000000000000000000001000000
  212. #define MenuItem8    0b0000000000000000000000010000000
  213. #define MenuItem9    0b0000000000000000000000100000000
  214. #define MenuItem10    0b0000000000000000000001000000000
  215. #define MenuItem11    0b0000000000000000000010000000000
  216. #define MenuItem12    0b0000000000000000000100000000000
  217.